from django.urls import include, path
from rest_framework_jwt.views import obtain_jwt_token, refresh_jwt_token

from user import views
from rest_framework.routers import SimpleRouter, DefaultRouter

# 自动生成路由方法, 必须使用视图集
# router = SimpleRouter()  # 没有根路由  /user/ 无法识别
router = DefaultRouter()  # 有根路由

router.register(r'user', views.UserViewSet)

urlpatterns = [
    path('count/',views.RegCountView.as_view()), # 查询用户名手机号使用量的视图,  /user/count/
    path('register/', views.RegisterVIew.as_view()),  # 注册视图
    path('index/', views.index),
    path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),  # 认证地址,
    path('api_index/', views.ApiView.as_view()),  # APIView类视图
    path('login/', obtain_jwt_token),  # 获取token
    path('refresh/', refresh_jwt_token),  # 刷新token

]
urlpatterns += router.urls
